package com.tansc.test.springboot.controller;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

@ServletComponentScan("com.tansc.test.springboot")
@ComponentScan("com.tansc.test.springboot")
@RestController
@EnableAutoConfiguration
public class Example {

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z");

    @RequestMapping("/")
    String home() {
        return "Hello World!";
    }

    @RequestMapping("/servlet/add/{name}")
    void addServlet(@PathVariable("name") String name){
        System.out.println(sdf.format(new Date()) + " =========> " + name);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Example.class, args);
    }

}